package org.creativor.rayson.server;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.net.InetSocketAddress;
import org.creativor.rayson.common.ClientSession;
import org.creativor.rayson.common.Invocation;
import org.creativor.rayson.common.RpcCallException;
import org.creativor.rayson.transport.common.Packet;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * The class <code>ServerCallTest</code> contains tests for the class
 * <code>{@link ServerCall}</code>.
 * <p>
 * Copyright Creativor Studio (c) 2011
 * 
 * @generatedBy CodePro at 11-5-7 上午2:58
 * @author Nick Zhang
 * @version $Revision: 1.0 $
 */
public class ServerCallTest {
	/**
	 * Launch the test.
	 * 
	 * @param args
	 *            the command line arguments
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	public static void main(String[] args) {
		new org.junit.runner.JUnitCore().run(ServerCallTest.class);
	}

	/**
	 * Perform pre-test initialization.
	 * 
	 * @throws Exception
	 *             if the initialization fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Before
	public void setUp() throws Exception {
		// TODO: add additional set up code here
	}

	/**
	 * Perform post-test clean-up.
	 * 
	 * @throws Exception
	 *             if the clean-up fails for some reason
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@After
	public void tearDown() throws Exception {
		// TODO: add additional tear down code here
	}

	/**
	 * Run the boolean exceptionCatched() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testExceptionCatched_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		boolean result = fixture.exceptionCatched();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertTrue(result);
	}

	/**
	 * Run the boolean exceptionCatched() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testExceptionCatched_2() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException((RpcCallException) null);

		boolean result = fixture.exceptionCatched();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertTrue(result);
	}

	/**
	 * Run the ServerCall fromPacket(InetSocketAddress,byte,Packet) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test(expected = java.io.EOFException.class)
	public void testFromPacket_1() throws Exception {
		InetSocketAddress remoteAddress = new InetSocketAddress(1);
		byte clientVersion = (byte) 1;
		Packet requestPacket = new Packet(new byte[] {});

		ServerCall result = ServerCall.fromPacket(remoteAddress, clientVersion,
				requestPacket);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the ServerCall fromPacket(InetSocketAddress,byte,Packet) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test(expected = java.io.EOFException.class)
	public void testFromPacket_2() throws Exception {
		InetSocketAddress remoteAddress = new InetSocketAddress(1);
		byte clientVersion = (byte) 1;
		Packet requestPacket = new Packet(new byte[] {});

		ServerCall result = ServerCall.fromPacket(remoteAddress, clientVersion,
				requestPacket);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the ServerCall fromPacket(InetSocketAddress,byte,Packet) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test(expected = java.io.EOFException.class)
	public void testFromPacket_3() throws Exception {
		InetSocketAddress remoteAddress = new InetSocketAddress(1);
		byte clientVersion = (byte) 1;
		Packet requestPacket = new Packet(new byte[] {});

		ServerCall result = ServerCall.fromPacket(remoteAddress, clientVersion,
				requestPacket);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the ServerCall fromPacket(InetSocketAddress,byte,Packet) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test(expected = java.io.EOFException.class)
	public void testFromPacket_4() throws Exception {
		InetSocketAddress remoteAddress = new InetSocketAddress(1);
		byte clientVersion = (byte) 1;
		Packet requestPacket = new Packet(new byte[] {});

		ServerCall result = ServerCall.fromPacket(remoteAddress, clientVersion,
				requestPacket);

		// TODO: add additional test code here
		assertNotNull(result);
	}

	/**
	 * Run the long getClientId() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetClientId_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		long result = fixture.getClientId();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertEquals(0L, result);
	}

	/**
	 * Run the ClientSession getClientSession() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetClientSession_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		ClientSession result = fixture.getClientSession();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertNotNull(result);
	}

	/**
	 * Run the long getCreationTime() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetCreationTime_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		long result = fixture.getCreationTime();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertEquals(0L, result);
	}

	/**
	 * Run the long getId() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetId_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		long result = fixture.getId();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertEquals(0L, result);
	}

	/**
	 * Run the Invocation getInvocation() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetInvocation_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		Invocation result = fixture.getInvocation();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertNotNull(result);
	}

	/**
	 * Run the Packet getResponsePacket() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetResponsePacket_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		Packet result = fixture.getResponsePacket();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertNotNull(result);
	}

	/**
	 * Run the Packet getResponsePacket() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testGetResponsePacket_2() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		Packet result = fixture.getResponsePacket();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertNotNull(result);
	}

	/**
	 * Run the void setException(RpcCallException) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testSetException_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());
		RpcCallException exception = new RpcCallException();

		fixture.setException(exception);

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
	}

	/**
	 * Run the void setResult(Object) method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testSetResult_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());
		Object result = new Object();

		fixture.setResult(result);

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
	}

	/**
	 * Run the String toString() method test.
	 * 
	 * @throws Exception
	 * 
	 * @generatedBy CodePro at 11-5-7 上午2:58
	 */
	@Test
	public void testToString_1() throws Exception {
		ServerCall fixture = ServerCall.fromPacket(new InetSocketAddress(1),
				(byte) 1, new Packet(new byte[] {}));
		fixture.setResult(new Object());
		fixture.setException(new RpcCallException());

		String result = fixture.toString();

		// TODO: add additional test code here
		// An unexpected exception was thrown in user code while executing this
		// test:
		// java.io.EOFException
		// at java.io.DataInputStream.readFully(DataInputStream.java:180)
		// at java.io.DataInputStream.readLong(DataInputStream.java:399)
		// at
		// org.creativor.rayson.server.ServerCall.fromPacket(ServerCall.java:50)
		assertNotNull(result);
	}
}